/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import org.jibble.pircbot.IrcException;

/**
 *
 * @author Bapiste
 */
public class CoyoteBoT {
    
    private static String line;
    private static String version = "0.0.1" ;

    public static void main(String[] args) throws FileNotFoundException, IOException, InterruptedException, IrcException {
        // TODO code application logic here
        
        Date date = new Date();
        
         // Présentation
       System.out.println("CoyoteBoT © version " +version); 
       System.out.println("Pour la team MQCD, et la communautée Urban Terror France");
       System.out.println("Par Asloon, protégé sous licence GNU/GPL");
       System.out.println("");
       System.out.print("Initialisation");
       
       for(int c = 0 ; c < 3 ; c++) {
       Thread.sleep(600);
       System.out.print(".");
       }
       
       System.out.println("\\");
       System.out.println("Date : " +date.toString());
       getAdresses();
       
       IrcBot bot = new IrcBot();
       bot.connect("irc.quakenet.org");
       bot.joinChannel("#MQCD");
       bot.sendMessage("#MQCD", "Done");
       bot.changeNick("Azloun");

       System.out.flush();
       
       
       ArrayList players = new ArrayList(0);
       
       String log_path = "C:\\Users\\Bapiste\\Desktop\\UrbanTerror\\q3ut4\\games.log" ;
       
       RandomAccessFile reader = new RandomAccessFile(log_path,"r");
       reader.seek(reader.length());
       
       while(true) {
           
           Thread.sleep(100);
       
       while((line = reader.readLine()) != null) {
           
                String[] split = line.split("\\");
          
           System.out.println(split[2]);
           
       }
       
       }
           
    }
    
static void getAdresses() throws UnknownHostException, MalformedURLException, IOException { 
        
//Get an instance of InetAdress for the LocalHost adress    
InetAddress thisIp = InetAddress.getLocalHost();  

//Print the host name
System.out.println("LocalHost Adress : " +thisIp.getHostAddress());

}

} 